package com.ybkj.daijia.api.weixin.handler.impl;

import com.ybkj.daijia.api.weixin.WxMsgType;
import com.ybkj.daijia.api.weixin.entity.WxBaseMsgEntity;
import com.ybkj.daijia.api.weixin.entity.WxBaseRespEntity;
import com.ybkj.daijia.api.weixin.entity.WxMsgTextEntity;
import com.ybkj.daijia.api.weixin.handler.WxHandler;
import java.util.Map;

public abstract class AbstractWxTextHandler implements WxHandler {

    @Override
    public Integer priority() {

        return 1;
    }


    @Override
    public boolean canHandle(WxBaseMsgEntity msg) {
        if (WxMsgType.valueOf(msg.getMsgType()).compareTo(WxMsgType.text) == 0) {

            return true;

        }

        return false;
    }


    @Override
    public WxBaseRespEntity doHandle(WxBaseMsgEntity msg, Map<String, Object> context,
        WxBaseRespEntity resp) {

        if (WxMsgType.valueOf(msg.getMsgType()).compareTo(WxMsgType.text) == 0) {

            return handleText((WxMsgTextEntity) msg, context, resp);

        }

        return resp;
    }

    public abstract WxBaseRespEntity handleText(WxMsgTextEntity msg, Map<String, Object> context,
        WxBaseRespEntity resp);

}
